package com.hustzp.com.xichuangzhu.me;


import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.hustzp.com.xichuangzhu.R;
import com.hustzp.com.xichuangzhu.fragment.ReViewFragment;
import com.hustzp.com.xichuangzhu.poetry.PoetryDetailAct;
import com.hustzp.com.xichuangzhu.poetry.model.Works;

/**
 * Created by chenxiaosong on 2016/5/29.
 */
public class AboutUsActivity extends MyBaseActivity {

    private RelativeLayout topWorks;
    private TextView verName, qq1Txt, qq2Txt, emailTxt, urlTxt;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
        initView();
    }

    private void initView() {
        topWorks = (RelativeLayout) findViewById(R.id.top_works);
        topWorks.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Works works = new Works();
                works.setId("10024");
                Intent intent = new Intent(AboutUsActivity.this, PoetryDetailAct.class);
                intent.putExtra("from", ReViewFragment.class.getSimpleName());
                intent.putExtra(Works.class.getSimpleName(), works);
                startActivity(intent);
            }
        });

        verName = (TextView) findViewById(R.id.tv_ver_name);
        try {
            PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
            verName.setText("v" + pi.versionName);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }

        qq1Txt = (TextView) findViewById(R.id.qq1_txt);
        qq2Txt = (TextView) findViewById(R.id.qq2_txt);
        emailTxt = (TextView) findViewById(R.id.email_txt);
        urlTxt = (TextView) findViewById(R.id.url_txt);
        emailTxt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                //设置文本格式
                emailIntent.setType("text/plain");
                //设置对方邮件地址
                emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, "hi@xichuangzhu.com");
                //设置标题内容
//                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.setting_recommend_words));
                //设置邮件文本内容
//                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.setting_recommend_words));
                startActivity(Intent.createChooser(emailIntent, "Choose Email Client"));
            }
        });
        qq1Txt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // QQ:2937033
                //http://qm.qq.com/cgi-bin/qm/qr?k=-_Qd9cInVHB9prGkg6ncdsLHbZxkBli9#
                String url = "http://qm.qq.com/cgi-bin/qm/qr?k=-_Qd9cInVHB9prGkg6ncdsLHbZxkBli9#"; // web address
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
            }
        });
        qq2Txt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // QQ:7473033
                String url = "http://jq.qq.com/?_wv=1027&k=27RTzgL"; // web address
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
            }
        });
        urlTxt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "http://www.xichuangzhu.com"; // web address
                Intent intent = new Intent(Intent.ACTION_VIEW);
                intent.setData(Uri.parse(url));
                startActivity(intent);
            }
        });

    }
}
